package com.itheima.dao;

import com.itheima.domain.Customer;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @version 1.0
 * @Author : wusiqi
 * @Date : 2019/3/7 20:47
 */
public interface CustomerDao {

    /*	private Long custId;
	private String custName;
	private String custIndustry;
	private String custAddress;
	private String custPhone;
	private String custLevel;
	private String custSource;*/
    //查询全部  字段不匹配  用results 重新定义
    @Select("select * from  cst_customer")
    @Results(id = "resultMap" ,value = {
            @Result(column = "cust_id" ,property = "custId"),
            @Result(column = "cust_Name" ,property = "custName"),
            @Result(column = "cust_Industry" ,property = "custIndustry"),
            @Result(column = "cust_Address" ,property = "custAddress"),
            @Result(column = "cust_Phone" ,property = "custPhone"),
            @Result(column = "cust_Level" ,property = "custLevel"),
            @Result(column = "cust_Source" ,property = "custSource"),
    })
    List<Customer> findAll();

    //引入定义好的result  并且根据id 查询数据
    @ResultMap("resultMap")
    @Select(" select * from cst_customer where cust_id=#{custId}")
    Customer findById(String custId);


    //把页面传过来的数据 提交到数据库 更改信息
  //  @ResultMap("resultMap")
    @Update(" update cst_customer set cust_Name=#{custName} ,cust_Industry=#{custIndustry} ," +
            "cust_Address=#{custAddress} ,cust_Phone=#{custPhone} ,cust_Level=#{custLevel} ,cust_Source=#{custSource} " +
            " where cust_id=#{custId}")
    void update(Customer customer);
}
